package mis.module.base.service.impl;

import java.util.List;

import mis.module.base.dao.ProductTypeDao;
import mis.module.base.model.ProductType;
import mis.module.base.service.ProductTypeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProductTypeServiceImpl implements ProductTypeService{
	@Autowired
	private ProductTypeDao productTypeDao;
	@Override
	public void saveProductType(ProductType productType) {
		// TODO Auto-generated method stub
		productTypeDao.save(productType);
	}

	@Override
	public void updateProductType(ProductType productType) {
		// TODO Auto-generated method stub
		productTypeDao.update(productType);
	}

	@Override
	public void deleteProductType(int id) {
		// TODO Auto-generated method stub
		productTypeDao.deleteById(id);
	}

	@Override
	public List<ProductType> findAllCustomer(int page, int rows, String sort,
			String order) {
		// TODO Auto-generated method stub
		return productTypeDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		// TODO Auto-generated method stub
		return productTypeDao.countAll();
	}

	@Override
	public boolean isExist(String productTypeNo) {
		// TODO Auto-generated method stub
		boolean flag = false;
		String hql="from Product as p where p.productNo="+productTypeNo;
		if (productTypeDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}

	public ProductTypeDao getProductTypeDao() {
		return productTypeDao;
	}

	public void setProductTypeDao(ProductTypeDao productTypeDao) {
		this.productTypeDao = productTypeDao;
	}

	@Override
	public ProductType getProductTypeById(int id) {
		// TODO Auto-generated method stub
		return productTypeDao.getById(ProductType.class, id);
	}

}
